################
#PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
#
#Observational Data: Eurobarometer
#Part II: Gini
#
#Verena Fetscher
#July 2022
####################

rm(list=ls())

####################
# Load data
####################
load("EB_17.rda")

gini<-read.csv("ilc_di12_1_Data.csv",encoding="utf8",sep=",", stringsAsFactors = FALSE)
names(gini) <- c("TIME","GEO","INDIC_IL","Value","Flag.and.Footnotes")

gini%>%
  filter(TIME==2017) -> gini_small


gini_small$GEO[gini_small$GEO=="Germany (until 1990 former territory of the FRG)"]<-"Germany"

colnames(gini_small) <- c("YEAR","cntry","inidc","gini","flags")

gini_small %>%
  dplyr::select(YEAR,cntry,gini)%>%
  mutate(gini=as.numeric(gini))-> gini_small

EB%>% 
  left_join(gini_small, by="cntry") -> EB

rm(gini,gini_small)


####################
# Save data
####################
save(EB, file = "EB_gini_17.Rda")

